#ifndef _WX_REGEX_H_
#define _WX_REGEX_H_

#include "wx/defs.h"

#if wxUSE_REGEX

#include "wx/string.h"

enum {
  wxRE_EXTENDED = 0,
  #ifdef wxHAS_REGEX_ADVANCED
  wxRE_ADVANCED = 1,
  #endif
  wxRE_BASIC = 2,
  wxRE_ICASE = 4,
  wxRE_NOSUB = 8,
  wxRE_NEWLINE = 16,
  wxRE_DEFAULT = wxRE_EXTENDED
};

enum {
  wxRE_NOTBOL = 32,
  wxRE_NOTEOL = 64
};

class wxRegExImpl;

class wxRegEx {
  public:
    wxRegEx() { Init(); }
    wxRegEx( const wxString& expr, int flags = wxRE_DEFAULT ) {
      Init();
      ( void )Compile( expr, flags );
    }
    bool IsValid() const { return m_impl != NULL; }
    bool Compile( const wxString& pattern, int flags = wxRE_DEFAULT );
    bool Matches( const wxChar *text, int flags = 0 ) const;
    bool Matches( const wxChar *text, int flags, size_t len ) const;
    bool Matches( const wxString& text, int flags = 0 ) const { return Matches( text.c_str(), flags, text.length() ); }
    bool GetMatch( size_t *start, size_t *len, size_t index = 0 ) const;
    wxString GetMatch( const wxString& text, size_t index = 0 ) const;
    size_t GetMatchCount() const;
    int Replace( wxString *text, const wxString& replacement, size_t maxMatches = 0 ) const;
    int ReplaceFirst( wxString *text, const wxString& replacement ) const { return Replace( text, replacement, 1 ); }
    int ReplaceAll( wxString *text, const wxString& replacement ) const { return Replace( text, replacement, 0 ); }
    ~wxRegEx();
  private:
    void Init();
    wxRegExImpl *m_impl;
    wxRegEx( const wxRegEx& );
    wxRegEx &operator=( const wxRegEx& );
};

#endif

#endif
